﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;

namespace Swimming.Manage
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultDB"].ConnectionString))
            {
                using (SqlCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandText = "select count(*) from [SEC_User] where [Type]='admin' and [LoginId]=@LoginId and [Password]=@Password";
                    cmd.Parameters.Add(new SqlParameter("LoginId", this.TextBox1.Text));
                    cmd.Parameters.Add(new SqlParameter("Password", this.TextBox2.Text));
                    conn.Open();
                    if (((int)cmd.ExecuteScalar()) > 0)
                    {
                        Session["admin"] = this.TextBox1.Text;
                        Response.Redirect("ActivityManage.aspx");
                    }
                    conn.Close();
                }
            }
        }
    }
}